using System;
using System.Xml.Serialization;

using SharpMud.Server.Systems.Net;
using SharpMud.Net.Telnet.Session;
using SharpMud.DynamicTyping;
using System.Collections.Generic;
using SharpMud.Net;

namespace SharpMud.Server.Systems.Net.Telnet
{
	[XmlRoot("TelnetServerConfiguration")]
    public class TelnetServerConfiguration<TTelnetSession> where TTelnetSession : TelnetSessionBase, IHasSessionState<TTelnetSession>, new()
	{
		private int _BasePort;
        private List<ListenerMetadatum<TTelnetSession>> _Listeners;

		public TelnetServerConfiguration()
		{
            _Listeners = new List<ListenerMetadatum<TTelnetSession>>();
		}

		[XmlElement("BasePort")]
		public int BasePort
		{
			get
			{
				return _BasePort;
			}
			set
			{
				_BasePort = value;
			}
		}

		public ListenerMetadatum<TTelnetSession>[] Listeners
		{
			get
			{
				return _Listeners.ToArray();
			}
			set
			{
				_Listeners.AddRange(value);
			}
		}

		[XmlIgnore]
		public List<ListenerMetadatum<TTelnetSession>> ListenersCollection
		{
			get
			{
				return _Listeners;
			}
		}

        //#region Default
        //public static TelnetServerConfiguration<TTelnetSession> Default
        //{
        //    get
        //    {
        //        TelnetServerConfiguration tsc = new TelnetServerConfiguration();
        //        tsc._BasePort = 4000;
        //        tsc._Listeners = new System.Collections.ArrayList();
        //        tsc._Listeners.Add( new ListenerMetadatum("telnet://:0",SharpMud.DynamicTyping.AssembliedTypeLocation.FromLoadedType(typeof(TelnetSessionBase))));
        //        return tsc;
        //    }
        //}
        //#endregion
	}
}